package com.villaday.idf.custom.pop;

import android.content.Context;
import android.graphics.Color;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.view.animation.Animation;
import android.widget.LinearLayout;

import com.villaday.idf.R;
import com.villaday.idf.adapter3.MenuChooseAdapter;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.custom.RVItemDecoration;
import com.villaday.idf.model.memberProfitsEntity;
import com.villaday.idf.util.PhoneUtil;

import java.util.List;

import razerdp.basepopup.BasePopupWindow;

public class TiXianHistoryPop extends BasePopupWindow {
    private TiXianHistoryPop.popuClick popuClick;

    public TiXianHistoryPop(Context context, List<memberProfitsEntity.BodyBean.BrokerageRecordParams> arokerageRecordParams, final popuClick popuClick) {
        super(context);
        this.popuClick = popuClick;

        RecyclerView rv = findViewById(R.id.rv);
        rv.setLayoutManager(new LinearLayoutManager(context));
        MenuChooseAdapter menuChooseAdapter = new MenuChooseAdapter(context);
        rv.addItemDecoration(new RVItemDecoration(LinearLayout.VERTICAL, PhoneUtil.dp2px(context, 1), Color.parseColor("#EEEEEE"), PhoneUtil.dp2px(context, 0)));
        rv.setAdapter(menuChooseAdapter);
        menuChooseAdapter.setData(arokerageRecordParams);
        menuChooseAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View v, int position) {
                popuClick.popuClick(position);
                dismiss();
            }
        });

    }

    // 必须实现，这里返回您的contentView
    // 为了让库更加准确的做出适配，强烈建议使用createPopupById()进行inflate
    @Override
    public View onCreateContentView() {
        return createPopupById(R.layout.menu_chose);
    }


    // 以下为可选代码（非必须实现）
    // 返回作用于PopupWindow的show和dismiss动画，本库提供了默认的几款动画，这里可以自由实现
    @Override
    protected Animation onCreateShowAnimation() {
        return getDefaultScaleAnimation(true);
    }

    @Override
    protected Animation onCreateDismissAnimation() {
        return getDefaultScaleAnimation(false);
    }

    public interface popuClick{
      void   popuClick(int position);
    }
}
